layui.config({
	base: '../lay/system/' //假设这是你存放拓展模块的根目录
}).extend({}).use(['layer', 'form', 'element'], function() {
	var layer = layui.layer,
		element = layui.element,
		form = layui.form,
		$ = layui.$;
	form.render();
	//提交
	form.on('submit(LAY-user-login-submit)', function(data) {
		var user_data = JSON.stringify(data.field);
		$.ajax({
			url: "http://127.0.0.1/api/admin/login",
			contentType: "application/x-www-form-urlencoded",
			headers: {
				"token": localStorage.getItem("token")
			},
			data: $('#login').serialize(),
			success: function(result, status, xhr) {
				localStorage.setItem("token", result.data.token);
				layer.closeAll('loading');
				layer.msg(result.msg, {
					icon: 1,
					time: 1000
				});
			}
		});
		return false;
	});
	form.verify({
		password: [
			/^[\S]{5,12}$/, '密码必须5到12位，且不能出现空格'
		]
	});

	//实际使用时记得删除该代码
	layer.msg('为了方便演示，用户名密码可随意输入', {
		offset: '15px',
		icon: 1
	});
	$('#qqLogin').click(function(){
		var A=window.open("oauth/index.php","TencentLogin","width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");
	})
});